int* intersection(int* nums1, int nums1Size, int* nums2, int nums2Size, int* returnSize) {
    int size = nums1Size < nums2Size ? nums1Size : nums2Size;
    int *res = (int *)malloc(sizeof(int) * size);
    int finalSize = 0;

    for(int i = 0; i < nums1Size; i++) {
        int isInter = 0;
        int isAdd = 0;
        for(int j = 0; j < nums2Size; j++) {
            if (nums2[j] == nums1[i]) {
                isInter = 1;
                if (isInter) {
                    for(int j = 0; j < finalSize; j++) {
                        if (nums1[i] == res[j]) {
                            isAdd = 1;
                            break;
                        }
                    }
                }
                if (!isAdd) {
                    res[finalSize++] = nums1[i];
                }
                break;
            }
        }
    }
    *returnSize = finalSize;
    return res;
}